package com.ctvit.sjk.knowledge.paragraph.controller;

import com.ctvit.sjk.knowledge.core.controller.KnowledgeController;
import com.ctvit.sjk.knowledge.core.page.TableRecordInfo;
import com.ctvit.sjk.knowledge.paragraph.service.ITabParagraphService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分段Controller
 *
 * @author heyingcheng
 * @date 2025/3/22
 */
@RestController
@RequestMapping("knowledge/dataset")
public class TabParagraphController extends KnowledgeController {

    private final ITabParagraphService tabParagraphService;

    public TabParagraphController(ITabParagraphService tabParagraphService) {
        this.tabParagraphService = tabParagraphService;
    }


    /**
     * 获取问题分段列表
     */
    @GetMapping("{datasetId}/problem/{problemId}/paragraph")
    public AjaxResult listProgramParagraph(@PathVariable String datasetId, @PathVariable String problemId) {
        return success(tabParagraphService.listProgramParagraph(datasetId, problemId));
    }

    /**
     * 获取文档分段列表
     */
    @GetMapping("{datasetId}/document/{documentId}/paragraph/{pageNum}/{pageSize}")
    public TableRecordInfo listDocumentParagraph(@PathVariable String datasetId,
                                         @PathVariable String documentId,
                                         @PathVariable Integer pageNum,
                                         @PathVariable Integer pageSize,
                                         @RequestParam(required = false) String title,
                                         @RequestParam(required = false) String content) {
        startPage(pageNum, pageSize);
        return getRecordTable(tabParagraphService.listDocumentParagraph(datasetId, documentId, title, content), pageNum, pageSize);
    }

}
